package com.gxa.zhonglong.service.impl;



import com.gxa.zhonglong.common.ExceptionCode;
import com.gxa.zhonglong.exception.BusinessException;
import com.gxa.zhonglong.mapper.GoodsClassMapper;
import com.gxa.zhonglong.pojo.GoodsClass;
import com.gxa.zhonglong.pojo.GoodsType;
import com.gxa.zhonglong.service.GoodsClassService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @author NITRO
 */

@Service("goodsClassService")
@Transactional(rollbackFor = {Throwable.class})
public class GoodsClassServiceImpl implements GoodsClassService {

    @Autowired
   private GoodsClassMapper goodsClassMapper;

    @Override
    public Boolean add(GoodsClass goodsClass) throws BusinessException {
        return goodsClassMapper.add(goodsClass);
    }

    @Override
    public void delete(List<Long> ids) throws BusinessException {
        if (goodsClassMapper.delete(ids)<1) {
            throw new BusinessException(ExceptionCode.DELETE_FALSE);
        }
    }

    @Override
    public Boolean update(GoodsClass goodsClass) throws BusinessException {
        Boolean aBoolean = goodsClassMapper.update(goodsClass);
        if(aBoolean){
            return true;
        }else{
            throw  new BusinessException(ExceptionCode.UPDATE_FALSE);
        }
    }

    @Override
    public List<GoodsClass> getList() {
        List<GoodsClass> select = goodsClassMapper.select();
        return select;
    }
}
